package bubblesn;
/**
 * Class to hold position in 2D array.
 * @author Rafalmag
 */
public class Coordinate {
	public int x;
	public int y;
	public Direction dir;
	
	
	/**
	 * Constructor
	 * @param X
	 * @param Y
	 * @param Dir initial {@link Direction}.
	 */
	public Coordinate(int X, int Y, Direction Dir) {
		x=X;
		y=Y;
		dir=Dir;
	}
	
	/**
	 * Copy constructor
	 * @param to
	 */
	public Coordinate(Coordinate to) {
		x=to.x;
		y=to.y;
		dir=to.dir;
	}
	

	/**
	 * Moves from current position to desired way
	 * @param toDir indicates in which direction is movement
	 * @return new Coordinate after movement
	 */
	public Coordinate go(Direction toDir){
		Coordinate tmp=new Coordinate(this);
		tmp.dir=toDir;
		switch(toDir){
			case down:
				tmp.y++;
				break;
			case up:
				tmp.y--;
				break;
			case right:
				tmp.x++;
				break;
			default:
				System.out.println("Error parsing Directon");
		}
		return tmp;
	}
}
